package dllDemo

import (
	"fmt"
	"syscall"
)

func StartDemo() {
	m1()
}

func m1() {
	dll, err := syscall.LoadLibrary("kernel32.dll")
	checkError(err)
	defer syscall.FreeLibrary(dll)
	proc, err := syscall.GetProcAddress(dll, "GetVersion")
	checkError(err)
	r, _, _ := syscall.Syscall(uintptr(proc), 0, 0, 0, 0)
	print("windows version ", byte(uint32(r)), ".", uint8(uint32(r)>>8), " (Build ", uint16(uint32(r)>>16), ")\n")
}

func checkError(err error) {
	if err != nil {
		fmt.Println(err)
		panic(err)
	}
}
